import { defineStore } from 'pinia'
import { ref, computed } from 'vue'

export const useLifeDeathStore = defineStore('lifeDeath', () => {
  // 状态
  const lifeRecords = ref([])
  const deathRecords = ref([])
  const specialCases = ref([])
  const loading = ref(false)
  const searchQuery = ref('')
  const filters = ref({
    status: 'all', // all, alive, dead, warning
    deathCause: 'all', // all, natural, accident, disaster, war, plague
    ageRange: [0, 200]
  })

  // 死因分类定义
  const deathCauses = ref({
    natural: {
      name: '自然死亡',
      subcategories: ['老衰', '疾病', '器官衰竭', '心脏病', '癌症', '中风']
    },
    accident: {
      name: '意外死亡',
      subcategories: ['交通事故', '溺水', '坠落', '中毒', '触电', '火灾', '其他意外']
    },
    disaster: {
      name: '自然灾害',
      subcategories: ['地震', '洪水', '台风', '山崩', '雷击', '干旱', '火山爆发']
    },
    war: {
      name: '战争伤亡',
      subcategories: ['战斗死亡', '战争饥荒', '战争疾病', '俘虏处决', '轰炸伤亡']
    },
    plague: {
      name: '瘟疫死亡',
      subcategories: ['天花', '黑死病', '霍乱', '伤寒', '流感', '其他传染病']
    }
  })

  // 辅助函数：生成事件描述
  const generateEventDescription = (causeType, specificCause) => {
    const descriptions = {
      accident: {
        交通事故: ['在十字路口发生两车相撞事故', '行人过马路时被车辆撞击', '车辆失控冲出道路护栏', '雨天路滑导致连环追尾'],
        溺水: ['在河边钓鱼时意外落水', '游泳时突发抽筋无法自救', '在水库游泳时遇到暗流', '儿童在池塘玩耍时溺水'],
        坠落: ['在建筑工地高空作业时失足', '爬山时失足从悬崖坠落', '楼房外墙清洁时安全绳断裂', '在家中擦拭高处窗户时失足'],
        火灾: ['家中电器短路引发火灾', '工厂车间突发爆炸起火', '森林大火蔓延至居民区', '厨房用火不慎引发火灾'],
        中毒: ['误食有毒蘑菇导致中毒', '一氧化碳泄漏导致中毒', '化工厂泄漏有毒气体', '食用变质食物导致食物中毒'],
        其他意外: ['触电事故导致死亡', '被重物砸中导致死亡', '窒息事故', '极端天气导致的意外']
      },
      disaster: {
        地震: ['突发7.2级强烈地震', '房屋倒塌被困废墟', '地震引发山体滑坡', '地震导致桥梁坍塌'],
        洪水: ['暴雨引发山洪暴发', '河堤决口洪水泛滥', '台风带来特大暴雨', '水库泄洪导致下游被淹'],
        台风: ['超强台风正面袭击', '台风引发巨浪冲击', '台风导致大树倒伏砸中', '台风引发泥石流'],
        山崩: ['连日暴雨引发山体滑坡', '地质松软导致山体垮塌', '开山采石引发山体不稳', '地震引发大规模山崩']
      },
      war: {
        战斗死亡: ['在前线战斗中阵亡', '城市攻防战中牺牲', '遭遇敌军伏击身亡', '在保卫家园战斗中殉国'],
        战争饥荒: ['长期围城导致饥饿', '战争破坏农业生产', '补给线被切断缺粮', '难民逃亡途中饥饿'],
        战争疾病: ['战争期间医疗匮乏', '难民营爆发传染病', '战地环境恶劣感染', '缺乏药物治疗病死'],
        轰炸伤亡: ['空袭轰炸中丧生', '炮击中不幸遇难', '爆炸中当场死亡', '建筑物被炸塌压死']
      },
      plague: {
        天花: ['感染天花病毒高烧不退', '天花大流行期间感染', '接触患者被传染天花', '天花引发严重并发症'],
        黑死病: ['感染鼠疫杆菌病情恶化', '黑死病大流行期间感染', '接触感染源传染鼠疫', '鼠疫引发败血症'],
        霍乱: ['饮用污染水源感染霍乱', '霍乱疫情期间被传染', '食用不洁食物感染', '霍乱引发严重脱水'],
        流感: ['感染流感病毒病情严重', '流感大流行期间感染', '免疫力低下感染流感', '流感引发肺炎并发症']
      }
    }

    const typeDesc = descriptions[causeType] || {}
    const causeDesc = typeDesc[specificCause] || ['发生了意外事件']
    return causeDesc[Math.floor(Math.random() * causeDesc.length)]
  }

  // 辅助函数：生成原因分析
  const generateCauseAnalysis = (causeType, specificCause) => {
    const analyses = {
      accident: {
        交通事故: ['驾驶员疲劳驾驶，注意力不集中', '车辆制动系统故障', '道路施工区域安全标识不足', '恶劣天气影响视线'],
        溺水: ['缺乏游泳技能和水中自救能力', '水域无安全警示和救生设备', '独自活动缺乏陪同人员', '对水域危险程度估计不足'],
        坠落: ['高空作业安全防护措施不到位', '安全绳索质量不合格或老化', '作业人员安全意识淡薄', '恶劣天气条件下强行作业'],
        火灾: ['电器线路老化存在安全隐患', '易燃物品存放不当', '消防设施配置不足', '火灾逃生知识缺乏'],
        中毒: ['对有毒物质识别能力不足', '安全防护措施不到位', '有毒物质处理不当', '应急救治措施缺失']
      },
      disaster: '自然灾害属于不可抗力，但预警系统和应急准备可以减少伤亡',
      war: '战争属于人为灾难，和平环境下可以避免此类悲剧',
      plague: '传染病传播与公共卫生防控措施密切相关'
    }

    const typeAnalysis = analyses[causeType]
    if (typeof typeAnalysis === 'object' && typeAnalysis[specificCause]) {
      const causeAnalyses = typeAnalysis[specificCause]
      return causeAnalyses[Math.floor(Math.random() * causeAnalyses.length)]
    }
    return typeof typeAnalysis === 'string' ? typeAnalysis : '需要进一步调查分析事件原因'
  }

  // 辅助函数：生成预防建议
  const generatePreventionSuggestions = (causeType, specificCause) => {
    const suggestions = {
      accident: {
        交通事故: ['加强交通安全教育和宣传', '完善道路交通标识和信号设施', '严格执行交通法规和处罚', '提高车辆安全技术标准'],
        溺水: ['在危险水域设置警示标志', '配备专业救生设备和人员', '加强游泳安全技能培训', '建立水域安全巡查制度'],
        坠落: ['规范高空作业安全操作流程', '配备合格的安全防护设备', '加强作业人员安全培训', '建立定期安全检查制度'],
        火灾: ['定期检查电器线路和设备', '合理配置消防器材', '加强火灾预防知识教育', '制定火灾应急疏散预案'],
        中毒: ['加强有毒物质管理和标识', '配备专业防护装备', '提供安全操作培训', '建立应急救治机制']
      },
      disaster: '完善自然灾害预警系统，加强应急预案建设和演练',
      war: '维护和平环境，通过外交途径解决争端',
      plague: '建立完善的公共卫生防控体系，加强疫情监测和应急响应'
    }

    const typeSuggestions = suggestions[causeType]
    if (typeof typeSuggestions === 'object' && typeSuggestions[specificCause]) {
      const causeSuggestions = typeSuggestions[specificCause]
      return causeSuggestions[Math.floor(Math.random() * causeSuggestions.length)]
    }
    return typeof typeSuggestions === 'string' ? typeSuggestions : '制定针对性的预防措施'
  }

  // 生成模拟数据
  const generateMockData = () => {
    const mockLifeRecords = []
    const mockDeathRecords = []
    const mockSpecialCases = []

    // 姓名数组
    const surnames = ['张', '李', '王', '刘', '陈', '杨', '赵', '黄', '周', '吴']
    const maleNames = ['文华', '志强', '建国', '明轩', '浩然', '子轩', '俊杰', '承志']
    const femaleNames = ['美丽', '秀英', '月华', '若汐', '语嫣', '诗涵', '心怡', '静怡']

    // 地点数组
    const locations = ['北京市朝阳区', '上海市浦东新区', '广州市天河区', '深圳市南山区', '杭州市西湖区', '南京市鼓楼区', '成都市锦江区', '武汉市武昌区']

    for (let i = 1; i <= 100; i++) {
      const isAlive = Math.random() > 0.3
      const gender = Math.random() > 0.5 ? 'male' : 'female'
      const surname = surnames[Math.floor(Math.random() * surnames.length)]
      const givenName = gender === 'male' ? maleNames[Math.floor(Math.random() * maleNames.length)] : femaleNames[Math.floor(Math.random() * femaleNames.length)]
      const name = surname + givenName

      // 基础信息
      const birthYear = 1900 + Math.floor(Math.random() * 120)
      const currentYear = 2024
      const currentAge = currentYear - birthYear
      const destinedLifespan = 60 + Math.floor(Math.random() * 40) // 60-100岁

      // 寿命记录
      const lifeRecord = {
        id: i,
        name,
        gender,
        birthDate: `${birthYear}-${String(Math.floor(Math.random() * 12) + 1).padStart(2, '0')}-${String(Math.floor(Math.random() * 28) + 1).padStart(2, '0')}`,
        destinedLifespan, // 天定寿命
        currentAge: isAlive ? currentAge : null,
        actualLifespan: isAlive ? null : Math.min(currentAge, destinedLifespan + Math.floor(Math.random() * 10) - 5), // 实际寿命可能有偏差
        remainingLife: isAlive ? Math.max(0, destinedLifespan - currentAge) : 0,
        status: isAlive ? 'alive' : 'dead',
        location: locations[Math.floor(Math.random() * locations.length)],
        profession: ['农民', '商人', '学者', '工匠', '官员'][Math.floor(Math.random() * 5)],
        karmaScore: Math.floor(Math.random() * 200) - 100, // -100到100的业力值
        warningLevel: isAlive ? (destinedLifespan - currentAge < 5 ? 'high' : destinedLifespan - currentAge < 15 ? 'medium' : 'low') : 'none',
        lastUpdate: new Date(Date.now() - Math.floor(Math.random() * 30) * 24 * 60 * 60 * 1000).toISOString()
      }

      mockLifeRecords.push(lifeRecord)

      // 如果已死亡，创建死亡记录
      if (!isAlive) {
        const deathCauseTypes = Object.keys(deathCauses.value)
        const causeType = deathCauseTypes[Math.floor(Math.random() * deathCauseTypes.length)]
        const subcategories = deathCauses.value[causeType].subcategories
        const specificCause = subcategories[Math.floor(Math.random() * subcategories.length)]

        const deathRecord = {
          id: i,
          lifeRecordId: i,
          name,
          deathDate: `${birthYear + lifeRecord.actualLifespan}-${String(Math.floor(Math.random() * 12) + 1).padStart(2, '0')}-${String(Math.floor(Math.random() * 28) + 1).padStart(2, '0')}`,
          deathTime: `${String(Math.floor(Math.random() * 24)).padStart(2, '0')}:${String(Math.floor(Math.random() * 60)).padStart(2, '0')}`,
          deathCause: causeType,
          specificCause,
          deathLocation: locations[Math.floor(Math.random() * locations.length)],
          lastWords: ['愿来世安好...', '家人要好好生活', '感谢此生所遇', '无愧于心...', '望子孙昌盛', '愿天下太平'][Math.floor(Math.random() * 6)],
          witnesses: Math.floor(Math.random() * 5) + 1,
          reportedBy: '家属',
          documentStatus: 'completed',
          notes: `${deathCauses.value[causeType].name}，${specificCause}导致死亡`
        }

        mockDeathRecords.push(deathRecord)

        // 特殊情况记录
        if (['accident', 'disaster', 'war', 'plague'].includes(causeType)) {
          const specialCase = {
            id: mockSpecialCases.length + 1,
            deathRecordId: i,
            name,
            caseType: causeType,
            severity: ['low', 'medium', 'high', 'critical'][Math.floor(Math.random() * 4)],
            affectedArea: locations[Math.floor(Math.random() * locations.length)],
            estimatedVictims: Math.floor(Math.random() * 1000) + 1,
            responseActions: ['已启动应急预案', '救援队伍已到位', '医疗救助进行中', '善后工作处理中'][Math.floor(Math.random() * 4)],
            investigationStatus: ['investigating', 'completed', 'pending', 'closed'][Math.floor(Math.random() * 4)],
            createdAt: new Date(Date.now() - Math.floor(Math.random() * 365) * 24 * 60 * 60 * 1000).toISOString(),

            // 为意外事件添加详细信息
            victimName: name,
            victimAge: lifeRecord.actualLifespan,
            victimGender: gender,
            eventType: causeType === 'accident' ? ['traffic', 'drowning', 'fall', 'fire', 'poisoning', 'other'][Math.floor(Math.random() * 6)] : causeType,
            eventTime: deathRecord.deathDate + 'T' + deathRecord.deathTime,
            location: deathRecord.deathLocation,
            witnesses: deathRecord.witnesses,
            description: generateEventDescription(causeType, specificCause),
            causeAnalysis: generateCauseAnalysis(causeType, specificCause),
            preventionSuggestions: generatePreventionSuggestions(causeType, specificCause)
          }

          mockSpecialCases.push(specialCase)
        }
      }
    }

    // 添加更多独立的意外事件记录（不一定导致死亡）
    const additionalAccidents = []
    for (let i = 1; i <= 30; i++) {
      const gender = Math.random() > 0.5 ? 'male' : 'female'
      const surname = surnames[Math.floor(Math.random() * surnames.length)]
      const givenName = gender === 'male' ? maleNames[Math.floor(Math.random() * maleNames.length)] : femaleNames[Math.floor(Math.random() * femaleNames.length)]
      const name = surname + givenName

      const eventTypes = ['traffic', 'drowning', 'fall', 'fire', 'poisoning', 'other']
      const eventType = eventTypes[Math.floor(Math.random() * eventTypes.length)]
      const eventTypeNameMap = {
        traffic: '交通事故',
        drowning: '溺水',
        fall: '坠落',
        fire: '火灾',
        poisoning: '中毒',
        other: '其他意外'
      }

      const age = 18 + Math.floor(Math.random() * 60) // 18-78岁
      const eventTime = new Date(Date.now() - Math.floor(Math.random() * 180) * 24 * 60 * 60 * 1000) // 最近半年

      const accident = {
        id: mockSpecialCases.length + additionalAccidents.length + 1,
        caseType: 'accident',
        victimName: name,
        victimAge: age,
        victimGender: gender,
        eventType: eventType,
        eventTime: eventTime.toISOString(),
        location: locations[Math.floor(Math.random() * locations.length)],
        severity: ['low', 'medium', 'high', 'critical'][Math.floor(Math.random() * 4)],
        witnesses: Math.floor(Math.random() * 8) + 1,
        investigationStatus: ['investigating', 'completed', 'pending', 'closed'][Math.floor(Math.random() * 4)],
        description: generateEventDescription('accident', eventTypeNameMap[eventType]),
        causeAnalysis: generateCauseAnalysis('accident', eventTypeNameMap[eventType]),
        preventionSuggestions: generatePreventionSuggestions('accident', eventTypeNameMap[eventType]),
        createdAt: eventTime.toISOString(),

        // 保留原有字段以兼容其他功能
        name: name,
        affectedArea: locations[Math.floor(Math.random() * locations.length)],
        estimatedVictims: 1,
        responseActions: ['现场处置完毕', '伤者已送医', '交通已恢复', '事故调查中'][Math.floor(Math.random() * 4)]
      }

      additionalAccidents.push(accident)
    }

    lifeRecords.value = mockLifeRecords
    deathRecords.value = mockDeathRecords
    specialCases.value = [...mockSpecialCases, ...additionalAccidents]

    // 添加独立的灾害事件数据
    const disasterEvents = []
    const disasterTypes = [
      { type: 'earthquake', name: '地震', severities: ['中度', '强烈', '特大'] },
      { type: 'flood', name: '洪水', severities: ['一般', '较大', '重大'] },
      { type: 'typhoon', name: '台风', severities: ['热带风暴', '强台风', '超强台风'] },
      { type: 'drought', name: '干旱', severities: ['轻度', '中度', '重度'] },
      { type: 'landslide', name: '山体滑坡', severities: ['小型', '中型', '大型'] },
      { type: 'fire', name: '山火', severities: ['局部', '区域性', '大面积'] }
    ]

    // 更详细的真实灾害事件数据
    const realDisasterEvents = [
      // 地震事件
      {
        name: '四川汶川大地震',
        disasterType: 'earthquake',
        severity: 'critical',
        severityLevel: '特大地震',
        startTime: '2008-05-12',
        endTime: '2008-05-12',
        location: '四川省汶川县',
        affectedArea: '10万平方公里',
        casualties: { deaths: 69227, injured: 374643, missing: 17923 },
        economicLoss: 8451000,
        description: '里氏8.0级特大地震，震中位于四川省阿坝藏族羌族自治州汶川县映秀镇',
        responseActions: '全国救援力量集结，十万官兵参与救援'
      },
      {
        name: '青海玉树地震',
        disasterType: 'earthquake',
        severity: 'high',
        severityLevel: '强烈地震',
        startTime: '2010-04-14',
        endTime: '2010-04-14',
        location: '青海省玉树藏族自治州',
        affectedArea: '3万平方公里',
        casualties: { deaths: 2698, injured: 12135, missing: 270 },
        economicLoss: 1200000,
        description: '里氏7.1级地震，震中位于玉树县结古镇',
        responseActions: '高原救援难度大，全力搜救被困人员'
      },
      {
        name: '四川雅安芦山地震',
        disasterType: 'earthquake',
        severity: 'high',
        severityLevel: '强烈地震',
        startTime: '2013-04-20',
        endTime: '2013-04-20',
        location: '四川省雅安市芦山县',
        affectedArea: '1.8万平方公里',
        casualties: { deaths: 196, injured: 11470, missing: 21 },
        economicLoss: 520000,
        description: '里氏7.0级地震，震中位于芦山县龙门乡',
        responseActions: '迅速启动应急响应，科学组织救援'
      },

      // 洪水事件
      {
        name: '1998年长江特大洪水',
        disasterType: 'flood',
        severity: 'critical',
        severityLevel: '特大洪水',
        startTime: '1998-06-12',
        endTime: '1998-09-10',
        location: '长江流域',
        affectedArea: '23万平方公里',
        casualties: { deaths: 1320, injured: 6852, missing: 874 },
        economicLoss: 1660000,
        description: '长江流域发生历史罕见特大洪水，多地告急',
        responseActions: '军民联防，确保荆江大堤等重要堤防安全'
      },
      {
        name: '河南郑州720特大暴雨',
        disasterType: 'flood',
        severity: 'critical',
        severityLevel: '特大暴雨',
        startTime: '2021-07-20',
        endTime: '2021-07-21',
        location: '河南省郑州市',
        affectedArea: '7400平方公里',
        casualties: { deaths: 302, injured: 50, missing: 0 },
        economicLoss: 532900,
        description: '郑州遭遇千年一遇特大暴雨，城市严重内涝',
        responseActions: '全力救援被困人员，紧急转移安置群众'
      },
      {
        name: '湖北荆州洪涝灾害',
        disasterType: 'flood',
        severity: 'high',
        severityLevel: '重大洪水',
        startTime: '2020-07-08',
        endTime: '2020-07-25',
        location: '湖北省荆州市',
        affectedArea: '1.4万平方公里',
        casualties: { deaths: 71, injured: 2186, missing: 35 },
        economicLoss: 280000,
        description: '持续强降雨导致长江水位暴涨，多地被淹',
        responseActions: '24小时巡堤查险，确保重要堤防安全'
      },

      // 台风事件
      {
        name: '台风利奇马',
        disasterType: 'typhoon',
        severity: 'critical',
        severityLevel: '超强台风',
        startTime: '2019-08-10',
        endTime: '2019-08-13',
        location: '浙江、江苏、山东等地',
        affectedArea: '6.2万平方公里',
        casualties: { deaths: 56, injured: 1515, missing: 14 },
        economicLoss: 515700,
        description: '今年最强台风登陆我国，风力达17级',
        responseActions: '提前转移危险区域人员，严防次生灾害'
      },
      {
        name: '台风山竹',
        disasterType: 'typhoon',
        severity: 'high',
        severityLevel: '强台风',
        startTime: '2018-09-16',
        endTime: '2018-09-17',
        location: '广东省',
        affectedArea: '3万平方公里',
        casualties: { deaths: 4, injured: 166, missing: 0 },
        economicLoss: 52000,
        description: '台风山竹强势登陆珠三角，风力达14级',
        responseActions: '史上最大规模台风防御，166万人转移'
      },

      // 干旱事件
      {
        name: '云南特大干旱',
        disasterType: 'drought',
        severity: 'critical',
        severityLevel: '特大干旱',
        startTime: '2009-10-01',
        endTime: '2010-05-31',
        location: '云南省',
        affectedArea: '15.8万平方公里',
        casualties: { deaths: 0, injured: 0, missing: 0 },
        economicLoss: 236000,
        description: '百年一遇特大旱灾，全省94%面积受旱',
        responseActions: '启动抗旱保供水应急预案，全力保民生'
      },
      {
        name: '华北地区春夏连旱',
        disasterType: 'drought',
        severity: 'high',
        severityLevel: '严重干旱',
        startTime: '2001-03-01',
        endTime: '2001-08-31',
        location: '华北地区',
        affectedArea: '12万平方公里',
        casualties: { deaths: 0, injured: 0, missing: 0 },
        economicLoss: 180000,
        description: '华北地区遭遇50年来最严重春夏连旱',
        responseActions: '实施人工增雨，合理调配水资源'
      },

      // 山体滑坡事件
      {
        name: '舟曲特大山洪泥石流',
        disasterType: 'landslide',
        severity: 'critical',
        severityLevel: '特大泥石流',
        startTime: '2010-08-08',
        endTime: '2010-08-08',
        location: '甘肃省舟曲县',
        affectedArea: '216平方公里',
        casualties: { deaths: 1765, injured: 1434, missing: 442 },
        economicLoss: 18200,
        description: '特大山洪泥石流灾害，县城大部被淹',
        responseActions: '全力搜救生还者，抢通生命通道'
      },
      {
        name: '贵州水城山体滑坡',
        disasterType: 'landslide',
        severity: 'high',
        severityLevel: '大型滑坡',
        startTime: '2019-07-23',
        endTime: '2019-07-23',
        location: '贵州省六盘水市',
        affectedArea: '128平方公里',
        casualties: { deaths: 42, injured: 9, missing: 9 },
        economicLoss: 8500,
        description: '持续降雨引发山体滑坡，多栋房屋被掩埋',
        responseActions: '紧急组织搜救，疏散周边群众'
      },

      // 森林火灾事件
      {
        name: '四川凉山森林火灾',
        disasterType: 'fire',
        severity: 'critical',
        severityLevel: '特大火灾',
        startTime: '2019-03-30',
        endTime: '2019-04-05',
        location: '四川省凉山州',
        affectedArea: '1000平方公里',
        casualties: { deaths: 31, injured: 3, missing: 0 },
        economicLoss: 15600,
        description: '森林大火突然爆燃，30名扑火队员英勇牺牲',
        responseActions: '全力扑救山火，严防复燃'
      },
      {
        name: '大兴安岭特大森林火灾',
        disasterType: 'fire',
        severity: 'critical',
        severityLevel: '特大火灾',
        startTime: '1987-05-06',
        endTime: '1987-06-02',
        location: '黑龙江省大兴安岭',
        affectedArea: '101万平方公里',
        casualties: { deaths: 213, injured: 226, missing: 0 },
        economicLoss: 500000,
        description: '新中国成立以来最严重的森林火灾',
        responseActions: '调集全国力量扑救，人工降雨辅助'
      }
    ]

    // 将真实事件数据转换为标准格式
    realDisasterEvents.forEach((event, index) => {
      const disasterEvent = {
        id: mockSpecialCases.length + additionalAccidents.length + disasterEvents.length + 1,
        name: event.name,
        caseType: 'disaster',
        disasterType: event.disasterType,
        disasterName: event.name,
        eventType: 'disaster',
        severity: event.severity,
        severityLevel: event.severityLevel,
        startTime: event.startTime, // 表格需要此字段
        endTime: event.endTime,
        location: event.location, // 模板显示需要此字段
        affectedArea: event.affectedArea, // 表格需要此字段
        casualties: event.casualties, // 模板显示伤亡情况需要此对象
        estimatedVictims: event.casualties.deaths + event.casualties.injured + event.casualties.missing, // 图表统计需要此字段
        economicLoss: event.economicLoss,
        responseActions: event.responseActions,
        investigationStatus: 'completed',
        description: event.description,
        createdAt: new Date(event.startTime).toISOString(),
        warningLevel: event.severity === 'critical' ? 'urgent' : event.severity === 'high' ? 'high' : 'medium'
      }
      disasterEvents.push(disasterEvent)
    })

    // 补充更多随机生成的灾害事件
    for (let i = 1; i <= 30; i++) {
      const disasterType = disasterTypes[Math.floor(Math.random() * disasterTypes.length)]
      const severity = disasterType.severities[Math.floor(Math.random() * disasterType.severities.length)]
      const startTime = new Date(Date.now() - Math.floor(Math.random() * 1095) * 24 * 60 * 60 * 1000) // 最近3年

      // 根据灾害类型调整伤亡规模
      let casualties = { deaths: 0, injured: 0, missing: 0 }
      let economicLoss = 0

      switch (disasterType.type) {
        case 'earthquake':
          casualties = {
            deaths: Math.floor(Math.random() * 200) + 10,
            injured: Math.floor(Math.random() * 1000) + 100,
            missing: Math.floor(Math.random() * 50)
          }
          economicLoss = Math.floor(Math.random() * 500000) + 50000
          break
        case 'flood':
          casualties = {
            deaths: Math.floor(Math.random() * 100) + 5,
            injured: Math.floor(Math.random() * 500) + 50,
            missing: Math.floor(Math.random() * 30)
          }
          economicLoss = Math.floor(Math.random() * 200000) + 20000
          break
        case 'typhoon':
          casualties = {
            deaths: Math.floor(Math.random() * 80) + 2,
            injured: Math.floor(Math.random() * 800) + 100,
            missing: Math.floor(Math.random() * 20)
          }
          economicLoss = Math.floor(Math.random() * 300000) + 30000
          break
        case 'drought':
          casualties = { deaths: 0, injured: 0, missing: 0 }
          economicLoss = Math.floor(Math.random() * 100000) + 10000
          break
        case 'landslide':
          casualties = {
            deaths: Math.floor(Math.random() * 60) + 1,
            injured: Math.floor(Math.random() * 200) + 10,
            missing: Math.floor(Math.random() * 15)
          }
          economicLoss = Math.floor(Math.random() * 50000) + 5000
          break
        case 'fire':
          casualties = {
            deaths: Math.floor(Math.random() * 40) + 1,
            injured: Math.floor(Math.random() * 100) + 5,
            missing: Math.floor(Math.random() * 10)
          }
          economicLoss = Math.floor(Math.random() * 80000) + 8000
          break
      }

      const disasterEvent = {
        id: mockSpecialCases.length + additionalAccidents.length + disasterEvents.length + 1,
        name: `${disasterType.name}事件-${String(Date.now()).slice(-6)}-${i}`,
        caseType: 'disaster',
        disasterType: disasterType.type,
        disasterName: disasterType.name,
        eventType: 'disaster',
        severity: ['low', 'medium', 'high', 'critical'][Math.floor(Math.random() * 4)],
        severityLevel: severity,
        startTime: startTime.toISOString().split('T')[0],
        endTime: new Date(startTime.getTime() + Math.floor(Math.random() * 14) * 24 * 60 * 60 * 1000).toISOString().split('T')[0],
        location: locations[Math.floor(Math.random() * locations.length)],
        affectedArea: `${Math.floor(Math.random() * 5000) + 500}平方公里`,
        casualties,
        estimatedVictims: casualties.deaths + casualties.injured + casualties.missing,
        economicLoss,
        responseActions: ['已启动应急预案，救援队伍到位', '紧急转移危险区域人员', '医疗救援队伍全力救治伤员', '专家组织灾情评估', '开展灾后重建工作', '加强次生灾害防范'][Math.floor(Math.random() * 6)],
        investigationStatus: ['investigating', 'completed', 'pending'][Math.floor(Math.random() * 3)],
        description: `${disasterType.name}${severity}，影响范围广泛，造成不同程度人员伤亡和经济损失`,
        createdAt: startTime.toISOString(),
        warningLevel: ['low', 'medium', 'high', 'urgent'][Math.floor(Math.random() * 4)]
      }

      disasterEvents.push(disasterEvent)
    }

    // 更新specialCases，合并所有数据
    specialCases.value = [...mockSpecialCases, ...additionalAccidents, ...disasterEvents]

    // 添加战争事件数据
    const warEvents = []

    // 真实历史战争事件数据
    const realWarEvents = [
      {
        name: '抗日战争',
        conflictType: 'invasion',
        startDate: '1937-07-07',
        endDate: '1945-08-15',
        location: '中国全境',
        scale: 'massive',
        status: 'ended',
        casualties: { deaths: 3500000, wounded: 1800000, missing: 200000 },
        description: '中华民族全面抗战，抵御日本侵略的伟大战争',
        commander: '国民政府军事委员会',
        battlefields: ['华北', '华东', '华南', '西南']
      },
      {
        name: '解放战争',
        conflictType: 'civil',
        startDate: '1946-06-26',
        endDate: '1950-05-01',
        location: '中国大陆',
        scale: 'massive',
        status: 'ended',
        casualties: { deaths: 1500000, wounded: 1100000, missing: 150000 },
        description: '中国人民解放军与国民党军队的决战',
        commander: '中央军委',
        battlefields: ['东北', '华北', '华东', '中原', '西北', '华南']
      },
      {
        name: '抗美援朝战争',
        conflictType: 'invasion',
        startDate: '1950-10-19',
        endDate: '1953-07-27',
        location: '朝鲜半岛',
        scale: 'large',
        status: 'ended',
        casualties: { deaths: 197653, wounded: 383218, missing: 25621 },
        description: '中国人民志愿军赴朝作战，保家卫国',
        commander: '志愿军司令部',
        battlefields: ['三八线', '汉城', '仁川', '上甘岭']
      },
      {
        name: '中越边境自卫反击战',
        conflictType: 'border',
        startDate: '1979-02-17',
        endDate: '1979-03-16',
        location: '中越边境',
        scale: 'medium',
        status: 'ended',
        casualties: { deaths: 6900, wounded: 14800, missing: 238 },
        description: '中国人民解放军对越自卫反击作战',
        commander: '广州军区',
        battlefields: ['东线', '西线']
      },
      {
        name: '中印边境反击战',
        conflictType: 'border',
        startDate: '1962-10-20',
        endDate: '1962-11-21',
        location: '中印边境',
        scale: 'medium',
        status: 'ended',
        casualties: { deaths: 722, wounded: 1697, missing: 0 },
        description: '中国军队在中印边境的自卫反击战',
        commander: '新疆军区、西藏军区',
        battlefields: ['东段', '西段']
      },
      {
        name: '珍宝岛冲突',
        conflictType: 'border',
        startDate: '1969-03-02',
        endDate: '1969-03-17',
        location: '珍宝岛',
        scale: 'small',
        status: 'ended',
        casualties: { deaths: 68, wounded: 94, missing: 0 },
        description: '中苏边境珍宝岛武装冲突',
        commander: '沈阳军区',
        battlefields: ['珍宝岛']
      }
    ]

    // 将真实战争事件转换为标准格式
    realWarEvents.forEach((event, index) => {
      const warEvent = {
        id: specialCases.value.length + warEvents.length + 1,
        name: event.name,
        caseType: 'war',
        conflictType: event.conflictType,
        startDate: event.startDate,
        endDate: event.endDate,
        location: event.location,
        scale: event.scale,
        status: event.status,
        casualties: event.casualties,
        description: event.description,
        commander: event.commander,
        battlefields: event.battlefields,
        estimatedVictims: event.casualties.deaths + event.casualties.wounded + event.casualties.missing,
        severity: event.scale === 'massive' ? 'critical' : event.scale === 'large' ? 'high' : 'medium',
        investigationStatus: 'completed',
        createdAt: new Date(event.startDate).toISOString(),
        responseActions: '军事指挥部统一指挥，全力组织作战',
        affectedArea: event.location,
        victimType: '军人'
      }
      warEvents.push(warEvent)
    })

    // 补充更多模拟战争事件
    const conflictTypes = ['civil', 'invasion', 'rebellion', 'border']
    const conflictTypeNames = {
      civil: '内战',
      invasion: '侵略战争',
      rebellion: '叛乱',
      border: '边境冲突'
    }

    for (let i = 1; i <= 20; i++) {
      const conflictType = conflictTypes[Math.floor(Math.random() * conflictTypes.length)]
      const startTime = new Date(Date.now() - Math.floor(Math.random() * 1095) * 24 * 60 * 60 * 1000) // 最近3年
      const duration = Math.floor(Math.random() * 365) + 1 // 1-365天
      const endTime = new Date(startTime.getTime() + duration * 24 * 60 * 60 * 1000)

      // 根据冲突类型调整伤亡规模
      let casualties = { deaths: 0, wounded: 0, missing: 0 }
      let scale = 'small'

      switch (conflictType) {
        case 'civil':
          casualties = {
            deaths: Math.floor(Math.random() * 5000) + 1000,
            wounded: Math.floor(Math.random() * 8000) + 2000,
            missing: Math.floor(Math.random() * 500) + 100
          }
          scale = ['medium', 'large'][Math.floor(Math.random() * 2)]
          break
        case 'invasion':
          casualties = {
            deaths: Math.floor(Math.random() * 8000) + 2000,
            wounded: Math.floor(Math.random() * 12000) + 3000,
            missing: Math.floor(Math.random() * 800) + 200
          }
          scale = ['large', 'massive'][Math.floor(Math.random() * 2)]
          break
        case 'rebellion':
          casualties = {
            deaths: Math.floor(Math.random() * 2000) + 500,
            wounded: Math.floor(Math.random() * 3000) + 800,
            missing: Math.floor(Math.random() * 200) + 50
          }
          scale = ['small', 'medium'][Math.floor(Math.random() * 2)]
          break
        case 'border':
          casualties = {
            deaths: Math.floor(Math.random() * 1000) + 100,
            wounded: Math.floor(Math.random() * 1500) + 300,
            missing: Math.floor(Math.random() * 100) + 20
          }
          scale = ['small', 'medium'][Math.floor(Math.random() * 2)]
          break
      }

      const warEvent = {
        id: specialCases.value.length + warEvents.length + 1,
        name: `${conflictTypeNames[conflictType]}-${String(Date.now()).slice(-6)}-${i}`,
        caseType: 'war',
        conflictType: conflictType,
        startDate: startTime.toISOString().split('T')[0],
        endDate: Math.random() > 0.3 ? endTime.toISOString().split('T')[0] : null, // 70%已结束，30%进行中
        location: locations[Math.floor(Math.random() * locations.length)],
        scale: scale,
        status: Math.random() > 0.3 ? 'ended' : Math.random() > 0.5 ? 'active' : 'ceasefire',
        casualties: casualties,
        description: `${conflictTypeNames[conflictType]}导致重大人员伤亡，影响地区安全稳定`,
        commander: ['军事指挥部', '联合作战司令部', '前线指挥所'][Math.floor(Math.random() * 3)],
        battlefields: [`${conflictTypeNames[conflictType]}主战场`, '次要战场'],
        estimatedVictims: casualties.deaths + casualties.wounded + casualties.missing,
        severity: scale === 'massive' ? 'critical' : scale === 'large' ? 'high' : scale === 'medium' ? 'medium' : 'low',
        investigationStatus: ['completed', 'investigating'][Math.floor(Math.random() * 2)],
        createdAt: startTime.toISOString(),
        responseActions: ['军事力量部署', '医疗救援队伍到位', '后勤保障跟进', '国际协调沟通'][Math.floor(Math.random() * 4)],
        affectedArea: locations[Math.floor(Math.random() * locations.length)],
        victimType: ['军人', '平民', '儿童', '老人'][Math.floor(Math.random() * 4)]
      }

      warEvents.push(warEvent)
    }

    // 添加瘟疫事件数据
    const plagueEvents = []

    // 真实历史瘟疫事件数据
    const realPlagueEvents = [
      {
        name: '1918年大流感',
        plagueType: 'viral',
        pathogen: '甲型H1N1流感病毒',
        startDate: '1918-03-01',
        endDate: '1920-04-01',
        location: '全球大流行',
        affectedArea: '全世界',
        casualties: { deaths: 50000000, infected: 500000000 },
        mortalityRate: 10.0,
        description: '1918年流感大流行，被称为西班牙流感，是人类历史上最严重的流感疫情'
      },
      {
        name: '黑死病',
        plagueType: 'bacterial',
        pathogen: '鼠疫耶尔森菌',
        startDate: '1347-01-01',
        endDate: '1353-12-31',
        location: '欧洲、亚洲',
        affectedArea: '欧亚大陆',
        casualties: { deaths: 200000000, infected: 300000000 },
        mortalityRate: 66.7,
        description: '14世纪黑死病大流行，导致欧洲三分之一人口死亡'
      },
      {
        name: 'SARS疫情',
        plagueType: 'viral',
        pathogen: 'SARS冠状病毒',
        startDate: '2002-11-01',
        endDate: '2003-07-31',
        location: '中国及多个国家',
        affectedArea: '32个国家和地区',
        casualties: { deaths: 774, infected: 8098 },
        mortalityRate: 9.6,
        description: '严重急性呼吸综合征疫情，首次在中国广东发现'
      },
      {
        name: 'COVID-19疫情',
        plagueType: 'viral',
        pathogen: 'SARS-CoV-2病毒',
        startDate: '2019-12-01',
        endDate: '2023-05-05',
        location: '全球大流行',
        affectedArea: '全世界',
        casualties: { deaths: 6900000, infected: 676000000 },
        mortalityRate: 1.0,
        description: '新型冠状病毒肺炎全球大流行'
      },
      {
        name: '霍乱第七次大流行',
        plagueType: 'bacterial',
        pathogen: '霍乱弧菌O1埃尔托型',
        startDate: '1961-01-01',
        endDate: '持续至今',
        location: '亚洲、非洲、南美洲',
        affectedArea: '100多个国家',
        casualties: { deaths: 1000000, infected: 5000000 },
        mortalityRate: 20.0,
        description: '第七次霍乱大流行，始于印尼，至今仍未完全结束'
      }
    ]

    // 将真实瘟疫事件转换为标准格式
    realPlagueEvents.forEach((event, index) => {
      const plagueEvent = {
        id: mockSpecialCases.length + additionalAccidents.length + disasterEvents.length + warEvents.length + index + 1,
        name: event.name,
        caseType: 'plague',
        plagueType: event.plagueType, // viral, bacterial, parasitic, unknown
        pathogen: event.pathogen, // 病原体名称
        severity: event.mortalityRate > 15 ? 'critical' : event.mortalityRate > 5 ? 'high' : 'medium',
        startTime: event.startDate,
        endTime: event.endDate,
        location: event.location,
        affectedArea: event.affectedArea,
        casualties: event.casualties,
        estimatedVictims: event.casualties.deaths + event.casualties.infected,
        mortalityRate: event.mortalityRate,
        responseActions: '启动公共卫生应急响应，实施防控措施',
        investigationStatus: 'completed',
        description: event.description,
        createdAt: new Date(event.startDate).toISOString(),

        // 为表格显示添加必要字段
        victimName: `${event.name}疫情`,
        victimAge: null,
        victimGender: null,
        infectionDate: event.startDate,
        onsetDate: event.startDate,
        deathDate: event.endDate
      }
      plagueEvents.push(plagueEvent)
    })

    // 生成模拟的瘟疫病例记录
    for (let i = 1; i <= 50; i++) {
      const plagueTypes = ['viral', 'bacterial', 'parasitic', 'unknown']
      const plagueType = plagueTypes[Math.floor(Math.random() * plagueTypes.length)]

      const pathogens = {
        viral: ['流感病毒H1N1', '流感病毒H3N2', '新冠病毒', 'SARS病毒', 'MERS病毒', '腺病毒'],
        bacterial: ['鼠疫杆菌', '霍乱弧菌', '炭疽杆菌', '伤寒杆菌', '白喉杆菌', '百日咳杆菌'],
        parasitic: ['疟原虫', '锥虫', '利什曼原虫', '弓形虫', '隐孢子虫', '贾第鞭毛虫'],
        unknown: ['未知病原体A型', '未知病原体B型', '未知病原体C型', '新发现病原体']
      }

      const pathogen = pathogens[plagueType][Math.floor(Math.random() * pathogens[plagueType].length)]
      const gender = Math.random() > 0.5 ? 'male' : 'female'
      const surname = surnames[Math.floor(Math.random() * surnames.length)]
      const givenName = gender === 'male' ? maleNames[Math.floor(Math.random() * maleNames.length)] : femaleNames[Math.floor(Math.random() * femaleNames.length)]
      const name = surname + givenName
      const age = Math.floor(Math.random() * 80) + 1

      // 生成时间线
      const infectionDate = new Date(Date.now() - Math.floor(Math.random() * 365) * 24 * 60 * 60 * 1000)
      const onsetDate = new Date(infectionDate.getTime() + Math.floor(Math.random() * 14) * 24 * 60 * 60 * 1000)
      const deathDate = new Date(onsetDate.getTime() + Math.floor(Math.random() * 30) * 24 * 60 * 60 * 1000)

      const plagueCase = {
        id: mockSpecialCases.length + additionalAccidents.length + disasterEvents.length + warEvents.length + plagueEvents.length + i,
        name: `瘟疫病例-${name}`,
        caseType: 'plague',
        plagueType: plagueType,
        pathogen: pathogen,
        severity: ['mild', 'moderate', 'severe', 'critical'][Math.floor(Math.random() * 4)],
        location: locations[Math.floor(Math.random() * locations.length)],
        affectedArea: locations[Math.floor(Math.random() * locations.length)],
        estimatedVictims: 1,
        responseActions: ['隔离治疗', '接触者追踪', '环境消毒', '医学观察'][Math.floor(Math.random() * 4)],
        investigationStatus: ['investigating', 'completed', 'pending'][Math.floor(Math.random() * 3)],
        description: `${name}感染${pathogen}，出现相关症状`,
        createdAt: infectionDate.toISOString(),

        // 表格显示字段
        victimName: name,
        victimAge: age,
        victimGender: gender,
        infectionDate: infectionDate.toISOString().split('T')[0],
        onsetDate: onsetDate.toISOString().split('T')[0],
        deathDate: deathDate.toISOString().split('T')[0]
      }

      plagueEvents.push(plagueCase)
    }

    // 更新specialCases，合并所有数据包括瘟疫事件
    specialCases.value = [...mockSpecialCases, ...additionalAccidents, ...disasterEvents, ...warEvents, ...plagueEvents]
  }

  // 计算属性
  const totalLifeRecords = computed(() => lifeRecords.value.length)
  const aliveCount = computed(() => lifeRecords.value.filter((record) => record.status === 'alive').length)
  const deadCount = computed(() => lifeRecords.value.filter((record) => record.status === 'dead').length)
  const warningCount = computed(() => lifeRecords.value.filter((record) => record.status === 'alive' && record.warningLevel === 'high').length)

  const averageLifespan = computed(() => {
    const deadRecords = lifeRecords.value.filter((record) => record.status === 'dead')
    if (deadRecords.length === 0) return 0
    const total = deadRecords.reduce((sum, record) => sum + record.actualLifespan, 0)
    return Math.round((total / deadRecords.length) * 10) / 10
  })

  const deathStatistics = computed(() => {
    const stats = {}
    Object.keys(deathCauses.value).forEach((cause) => {
      stats[cause] = deathRecords.value.filter((record) => record.deathCause === cause).length
    })
    return stats
  })

  // 筛选后的记录
  const filteredLifeRecords = computed(() => {
    let filtered = lifeRecords.value

    // 搜索过滤
    if (searchQuery.value) {
      const query = searchQuery.value.toLowerCase()
      filtered = filtered.filter((record) => record.name.toLowerCase().includes(query) || record.location.toLowerCase().includes(query) || record.profession.toLowerCase().includes(query))
    }

    // 状态过滤
    if (filters.value.status !== 'all') {
      if (filters.value.status === 'warning') {
        filtered = filtered.filter((record) => record.status === 'alive' && record.warningLevel === 'high')
      } else {
        filtered = filtered.filter((record) => record.status === filters.value.status)
      }
    }

    // 年龄范围过滤
    filtered = filtered.filter((record) => {
      const age = record.status === 'alive' ? record.currentAge : record.actualLifespan
      return age >= filters.value.ageRange[0] && age <= filters.value.ageRange[1]
    })

    return filtered
  })

  const filteredDeathRecords = computed(() => {
    let filtered = deathRecords.value

    // 搜索过滤
    if (searchQuery.value) {
      const query = searchQuery.value.toLowerCase()
      filtered = filtered.filter((record) => record.name.toLowerCase().includes(query) || record.deathLocation.toLowerCase().includes(query) || record.specificCause.toLowerCase().includes(query))
    }

    // 死因过滤
    if (filters.value.deathCause !== 'all') {
      filtered = filtered.filter((record) => record.deathCause === filters.value.deathCause)
    }

    return filtered
  })

  const filteredSpecialCases = computed(() => {
    let filtered = specialCases.value

    // 搜索过滤
    if (searchQuery.value) {
      const query = searchQuery.value.toLowerCase()
      filtered = filtered.filter((record) => record.name.toLowerCase().includes(query) || record.affectedArea.toLowerCase().includes(query) || record.caseType.toLowerCase().includes(query))
    }

    return filtered
  })

  // 方法
  const fetchLifeRecords = async () => {
    loading.value = true
    try {
      // 模拟API调用
      await new Promise((resolve) => setTimeout(resolve, 1000))
      if (lifeRecords.value.length === 0) {
        generateMockData()
      }
    } catch (error) {
      console.error('获取寿命记录失败:', error)
    } finally {
      loading.value = false
    }
  }

  const addLifeRecord = async (recordData) => {
    loading.value = true
    try {
      const newRecord = {
        id: Date.now(),
        ...recordData,
        status: 'alive',
        currentAge: new Date().getFullYear() - new Date(recordData.birthDate).getFullYear(),
        remainingLife: Math.max(0, recordData.destinedLifespan - (new Date().getFullYear() - new Date(recordData.birthDate).getFullYear())),
        warningLevel: 'low',
        lastUpdate: new Date().toISOString()
      }
      lifeRecords.value.unshift(newRecord)
      return newRecord
    } catch (error) {
      console.error('添加寿命记录失败:', error)
      throw error
    } finally {
      loading.value = false
    }
  }

  const addDeathRecord = async (recordData) => {
    loading.value = true
    try {
      const newRecord = {
        id: Date.now(),
        ...recordData,
        documentStatus: 'completed'
      }
      deathRecords.value.unshift(newRecord)

      // 更新对应的寿命记录状态
      const lifeRecord = lifeRecords.value.find((record) => record.id === recordData.lifeRecordId)
      if (lifeRecord) {
        lifeRecord.status = 'dead'
        lifeRecord.actualLifespan = recordData.ageAtDeath
        lifeRecord.remainingLife = 0
        lifeRecord.warningLevel = 'none'
      }

      return newRecord
    } catch (error) {
      console.error('添加死亡记录失败:', error)
      throw error
    } finally {
      loading.value = false
    }
  }

  const addSpecialCase = async (caseData) => {
    loading.value = true
    try {
      const newCase = {
        id: Date.now(),
        ...caseData,
        createdAt: new Date().toISOString()
      }
      specialCases.value.unshift(newCase)
      return newCase
    } catch (error) {
      console.error('添加特殊情况记录失败:', error)
      throw error
    } finally {
      loading.value = false
    }
  }

  const updateLifeRecord = async (id, updateData) => {
    const index = lifeRecords.value.findIndex((record) => record.id === id)
    if (index !== -1) {
      lifeRecords.value[index] = { ...lifeRecords.value[index], ...updateData, lastUpdate: new Date().toISOString() }
      return lifeRecords.value[index]
    }
    throw new Error('记录不存在')
  }

  const deleteLifeRecord = async (id) => {
    const index = lifeRecords.value.findIndex((record) => record.id === id)
    if (index !== -1) {
      lifeRecords.value.splice(index, 1)
      // 同时删除相关的死亡记录
      const deathIndex = deathRecords.value.findIndex((record) => record.lifeRecordId === id)
      if (deathIndex !== -1) {
        deathRecords.value.splice(deathIndex, 1)
      }
      return true
    }
    return false
  }

  const setSearchQuery = (query) => {
    searchQuery.value = query
  }

  const setFilters = (newFilters) => {
    filters.value = { ...filters.value, ...newFilters }
  }

  const resetFilters = () => {
    filters.value = {
      status: 'all',
      deathCause: 'all',
      ageRange: [0, 200]
    }
    searchQuery.value = ''
  }

  // 初始化时加载数据
  if (lifeRecords.value.length === 0) {
    generateMockData()
  }

  return {
    // 状态
    lifeRecords,
    deathRecords,
    specialCases,
    loading,
    searchQuery,
    filters,
    deathCauses,

    // 计算属性
    totalLifeRecords,
    aliveCount,
    deadCount,
    warningCount,
    averageLifespan,
    deathStatistics,
    filteredLifeRecords,
    filteredDeathRecords,
    filteredSpecialCases,

    // 方法
    fetchLifeRecords,
    addLifeRecord,
    addDeathRecord,
    addSpecialCase,
    updateLifeRecord,
    deleteLifeRecord,
    setSearchQuery,
    setFilters,
    resetFilters
  }
})
